<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>下发页面 | </title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="css/font-awesome.min.css" rel="stylesheet">
    <!-- NProgress -->
    <!--<link href="css/nprogress.css" rel="stylesheet">-->
    <!-- FullCalendar -->
    <link href="css/fullcalendar.min.css" rel="stylesheet">
    <link href="css/fullcalendar.print.css" rel="stylesheet" media="print">
    <style>
    	
    	#bbb{
    		margin: 2px 90px;
    		float: left;
    		display: none;
    	}
    </style>
	
		
    <!-- Custom styling plus plugins -->
    <link href="css/custom.min.css" rel="stylesheet">
  </head>

  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
       <div id="head">
       	
       </div>

        

        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
            <div class="page-title">
              <div class="title_left">
              	<div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">
               <div class="input-group">
                <input type="text" class="form-control" id="orderNo" placeholder="订单号">
                    <span class="input-group-btn">
                      <button class="btn btn-default gaoGetOrder" type="button">搜索</button>
                    </span>
                    
                      </div>
                      
                         </div>
              </div>

              <div class="title_right"	style="margin-top: 8px;">
                    <!-- <h3>右边数据<small>Click to add/edit events</small></h3>-->
                     	<!--<a href="http://www.baidu.com"></a>--> 
                     	<a class="collapse-link" id="gsearch"><i class="fa fa-chevron-up">高级搜索</i></a>
                     	 
              </div>
              <div class="row" id="bbb">
              		<div style="margin-left: 1000px;">
              				<button type="button" class="btn btn-info getOrder">开始搜索</button>
              			</div>
              	<form>
              					<div class="row">
                          <label class="col-sm-1 control-label" style="text-align: right;" for="orderNumber">订单号：</label>
                          <div class="col-sm-2">
                             <input class="form-control" id="orderNumber" type="text" />
                          </div>
                          <label class="col-sm-1 control-label" style="text-align: right;" for="bookingid">订舱申请号：</label>
                          <div class="col-sm-2">
                             <input class="form-control"  id="bookingid" type="text" />
                          </div>
                          <label class="col-sm-1 control-label" style="text-align: right;" for="statusid">任务状态：</label>
                          <div class="col-sm-2">
                                 <input class="form-control"  id="statusid" type="text" />
                           </div>

                       </div>
                       <div class="row" style="margin-bottom: 8px;">
                          <label class="col-sm-1 control-label" style="text-align: right;" for="exportorgname">出口组织：</label>
                          <div class="col-sm-2">
                             <input class="form-control" id="exportorgname" type="text" 	/>
                          </div>
                          <label class="col-sm-1 control-label" style="text-align: right;" for="salesmanid">业务员：</label>
                          <div class="col-sm-2">
                             <input class="form-control" id="salesmanid" type="text" />
                          </div>
                           <label class="col-sm-1 control-label" style="text-align: right;" for="customerId">客户：</label>
                          <div class="col-sm-2">
                             <input class="form-control"  id="customerId" type="text" />
                          </div>
                       </div>
                       <div class="row" style="margin-bottom: 8px;">

                       </div>

    										</form>		
    									</div>
    									
    										
            </div>
				
            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>订单下发</h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                    
                      
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">

                   

                    <!-- start project list -->
                    <table id="table1" class="table table-striped projects">
                      <thead>
                        <tr>
                          <th style="width: 6%"></th>
                          <th style="width: 6%">集拼号</th>
                          <th style="width: 6%">订单号</th>
                          <th style="width: 6%">订舱申请号</th>
                          <th style="width: 15%">客户名称出口组织</th>
                          <th style="width: 18%">区域业务员</th>
                          <th style="width: 5%">运输方式</th>	
                          <th style="width: 12%">启运港目的港</th>
                          <th style="width: 8%">订单接入日期</th>
                          <th style="width: 5%">任务状态</th>
                          <th style="width: 10%">操作</th>
                        </tr>
                      </thead>

                    </table>
                    <!-- end project list -->
                      <span id="tableError" style="display: none;color: red;font-size: 20px;margin-left:550px"></span>
                  </div>
                </div>
              </div>
          </div>
        </div>
        <!-- /page content -->

        <!-- footer content -->
        <footer>
 
														    <div class="checkbox-custom checkbox-default" >
														        <input type="checkbox" id="RememberMe1" name="procheck" class="aa">
														            <label  class="aa"></label>	全选
														    </div>
									
													
							
        	<button type="button" class="btn btn-info xiafa">下发</button>
        	<button type="button" class="btn btn-success allxiafa">集拼下发</button>
        	<div class="btn-group">
    			<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">更多
        	<span class="caret"></span>
    			</button>
    <ul class="dropdown-menu" role="menu">
         <li>
            <a href="javascript:;" id="guaqi">挂起</a>
        </li>
        <li>
            <a href="javascript:;" id="noguaqi">取消挂起</a>
        </li>
    </ul>
</div>
            <div class="pull-right" style="margin-top: 38px;">
                <ul class="pagination" id="ye">

                </ul>
            </div>
          <!--<div class="clearfix"></div>-->
        </footer>
        <!-- /footer content -->
      </div>
    </div>

    <!-- calendar modal -->
    <div id="CalenderModalNew" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">

          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h4 class="modal-title" id="myModalLabel">New Calendar Entry</h4>
          </div>
          <div class="modal-body">
            <div id="testmodal" style="padding: 5px 20px;">
              <form id="antoform" class="form-horizontal calender" role="form">
                <div class="form-group">
                  <label class="col-sm-3 control-label">Title</label>
                  <div class="col-sm-9">
                    <input type="text" class="form-control" id="title" name="title">
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label">Description</label>
                  <div class="col-sm-9">
                    <textarea class="form-control" style="height:55px;" id="descr" name="descr"></textarea>
                  </div>
                </div>
              </form>
            </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default antoclose" data-dismiss="modal">Close</button>
            <button type="button" class="btn btn-primary antosubmit">Save changes</button>
          </div>
        </div>
      </div>
    </div>
    <div id="CalenderModalEdit" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">

          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h4 class="modal-title" id="myModalLabel2">Edit Calendar Entry</h4>
          </div>
          <div class="modal-body">

            <div id="testmodal2" style="padding: 5px 20px;">
              <form id="antoform2" class="form-horizontal calender" role="form">
                <div class="form-group">
                  <label class="col-sm-3 control-label">Title</label>
                  <div class="col-sm-9">
                    <input type="text" class="form-control" id="title2" name="title2">
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label">Description</label>
                  <div class="col-sm-9">
                    <textarea class="form-control" style="height:55px;" id="descr2" name="descr"></textarea>
                  </div>
                </div>

              </form>
            </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default antoclose2" data-dismiss="modal">Close</button>
            <button type="button" class="btn btn-primary antosubmit2">Save changes</button>
          </div>
        </div>
      </div>
    </div>
    </div>
    <div id="fc_create" data-toggle="modal" data-target="#CalenderModalNew"></div>
    <div id="fc_edit" data-toggle="modal" data-target="#CalenderModalEdit"></div>
    <!-- /calendar modal -->
        
    <!-- jQuery -->
    <script src="js/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="js/bootstrap.min.js"></script>
    <!-- FastClick -->
    <script src="js/fastclick.js"></script>
    <!-- NProgress -->
    <script src="js/nprogress.js"></script>
    <!-- FullCalendar -->
    <script src="js/moment.min.js"></script>
    <script src="js/fullcalendar.min.js"></script>
    <script src="js/icheck.min.js"></script>

    <!-- Custom Theme Scripts -->
    <!--<script src="js/custom.min.js"></script>-->
	
		<style >
			.checkbox-custom {
    position: relative;
    padding: 0 15px 0 25px;
    margin-bottom: 7px;
    margin-top: 0;
    display: inline-block;
}
/*
将初始的checkbox的样式改变
*/
.checkbox-custom input[type="checkbox"] {
    opacity: 0;/*将初始的checkbox隐藏起来*/
    position: absolute;
    cursor: pointer;
    z-index: 2;
    margin: -6px 0 0 0;
    top: 50%;
    left: 3px;
}
/*
设计新的checkbox，位置
*/
.checkbox-custom label:before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    margin-top: -9px;
    width: 19px;
    height: 18px;
    display: inline-block;
    border-radius: 2px;
    border: 1px solid #bbb;
    background: #eee;
}
/*
点击初始的checkbox，将新的checkbox关联起来
*/
.checkbox-custom input[type="checkbox"]:checked +label:after {
    position: absolute;
    display: inline-block;
    font-family: 'Glyphicons Halflings';
    content: "\e013";
    top: 48%;
    left: 4px;
    margin-top: -5px;
    font-size: 11px;
    line-height: 1;
    width: 16px;
    height: 16px;
    color: #333;
}
.checkbox-custom label {
    cursor: pointer;
    line-height: 1.2;
    font-weight: normal;/*改变了rememberme的字体*/
    margin-bottom: 0;
    text-align: left;
}
			
		</style>
    <!-- FullCalendar -->
    <script>
        function   formatDate(now)   {
            var   year=now.getFullYear();
            var   month=now.getMonth()+1;
            var   date=now.getDate();
            return   year+"-"+month+"-"+date;
        }

        var $token=window.sessionStorage.getItem('token');
        var $orderNumber = $("#orderNumber").val();
        var $bookingid = $("#bookingid").val();
        var $statusid = $("#statusid").val();
        var $exportorgname = $("#exportorgname").val();
        var $salesmanid = $("#salesmanid").val();
        var $customerId = $("#customerId").val();


        $.ajax({
            type:"post",
            xhrFields:{withCredentials:true},
            url:"http://localhost:8081/OrderController/faOrder",
            dataType:"json",
            data:{"orderNumber":$orderNumber,"bookingid":$bookingid,"statusid":$statusid,"exportorgname":$exportorgname,"salesmanid":$salesmanid,"customerName":$customerId,"token":$token},
            success:function (data) {
                if(data.list==0){
                    $("#table1").hide();
                    $("#tableError").show();
                    $("#tableError").html("抱歉,未找到数据");
                    return;
                }
                $("#tableError").hide();
                $("#table1").show();
                $('#table1 tbody').remove();
                $.each(data.list,function(i,Order) {
                    var $tr = $('<tr></tr>');

                    var $td = $('<td><div class="col-sm-8 ">\n' +
                        '                        <div class="checkbox-custom checkbox-default">\n' +
                        '                        <input class="procheck1" type="checkbox" spelno="'+Order.spelno+'" status="'+Order.statusid+'" bookingno="'+Order.bookingid+'" value="'+Order.orderNumber+'" name="procheck">\n' +
                        '                        <label for="RememberMe" ></label>\n' +
                        '                        </div>\n' +
                        '                        </div></td>');
                    $tr.append($td);


                    $td = $('<td></td>');
                    $td.text(Order.spelno);
                    $tr.append($td);


                    $td = $('<td></td>');
                    $td.text(Order.orderNumber);
                    $tr.append($td);

                    $td = $('<td></td>');
                    $td.text(Order.bookingid);
                    $tr.append($td);

                    $td = $('<td></td>');
                    $td.text(Order.senderName+"/"+Order.goodDescription);
                    $tr.append($td);

                    $td = $('<td></td>');
                    $td.text(Order.cAddress+"/"+Order.cUsername);
                    $tr.append($td);

                    $td = $('<td></td>');
                    if (Order.shippingType==1 ){
                        $td.text("海运");
                    }else {
                        $td.text("空运");
                    }
                    $tr.append($td);


                    $td = $('<td></td>');
                    $td.text(Order.loadingport+"/"+Order.dischargeport);
                    $tr.append($td);

                    var   d=new   Date(Order.ordertime);
                    $td = $('<td></td>');
                    $td.text(formatDate(d));
                    $tr.append($td);



                    $td = $('<td></td>');
                    if (Order.statusid==6) {
                        $td.html('<button type="button" class="btn btn-success btn-xs">已反馈</button>');

                    }else if (Order.statusid==20) {
                        $td.html('<button type="button" class="btn btn-info btn-xs">已下发</button>');
                    }else if (Order.statusid==35) {
                        $td.html('<button type="button" class="btn btn-success btn-xs">已报关</button>');
                    }else {
                        $td.html('<button type="button" class="btn btn-info btn-xs">挂起</button>');
                    }
                    $tr.append($td);

                    $td = $('<td style="display: none"></td>');
                    $td.text(Order.id);
                    $tr.append($td);

                    $td = $('<td style="display: none"></td>');
                    $td.text(Order.statusid);
                    $tr.append($td);


                    $td = $('<td></td>');
                    $td.html('<a href="javascript:;" orderNumber="'+Order.orderNumber+'" class="btn btn-primary btn-xs showOrderAll" style="padding: 2px 8px;"><i class="fa fa-search-plus"></i></a>\n' +
                        '                    <a href="javascript:;" orderNumber="'+Order.orderNumber+'" status="'+Order.statusid+'" class="btn btn-danger btn-xs xiafa2" style="padding: 2px 8px;"><i class="fa fa-sort-amount-asc"></i></a>');
                    $tr.append($td);
                    $('#table1').append($tr);


                })

                $('#ye').prepend('<li><a class="page1" href="javascript:;" pageNum="'+(data.pageNum-1)+'" >&laquo;</a></li >');
                $("#ye").append('<li><a>'+data.pageNum+"/"+data.pages+'</a></li>');
                $('#ye').append('<li><a class="page1" href="javascript:;" pageNum="'+(data.pageNum+1)+'">&raquo;</a></li>');
            },
            error:function(){
                alert("错误");
            }
        })
        <!--end页面初始化ajax-->



        //高级搜索
        $(document).on("click",".getOrder",function () {
            var $pagenum=$(this).attr("pageNum");
            var $orderNumber = $("#orderNumber").val();
            var $bookingid = $("#bookingid").val();
            var $statusid = $("#statusid").val();
            var $exportorgname = $("#exportorgname").val();
            var $salesmanid = $("#salesmanid").val();
            var $customerId = $("#customerId").val();
            var $pattern = /^\d{1,3}$/;
            var $bookingidpattern = /^\d{3,5}$/;
            if ($bookingid != "" && !($bookingidpattern.test($bookingid))){
                $("#table1").hide();
                $("#tableError").show();
                $("#tableError").html("抱歉,未找到数据");
                return;
            }else if ($statusid != "" && !($pattern.test($statusid))){
                $("#table1").hide();
                $("#tableError").show();
                $("#tableError").html("抱歉,未找到数据");
                return;
            }else if ($salesmanid != "" && !($pattern.test($salesmanid))){
                $("#table1").hide();
                $("#tableError").show();
                $("#tableError").html("抱歉,未找到数据");
                return;
            } else {
                $.ajax({
                    type:"post",
                    xhrFields:{withCredentials:true},
                    url:"http://localhost:8081/OrderController/faOrder",
                    dataType:"json",
                    data:{"orderNumber":$orderNumber,"bookingid":$bookingid,"statusid":$statusid,"exportorgname":$exportorgname,"salesmanid":$salesmanid,"customerName":$customerId,"pageNum":$pagenum,"token":$token},
                    success:function (data) {
                        if(data.list==0){
                            $("#table1").hide();
                            $("#tableError").show();
                            $("#tableError").html("抱歉,未找到数据");
                            return;
                        }
                        $("#tableError").hide();
                        $("#table1").show();
                        $('#table1 tbody').remove();
                        $.each(data.list,function(i,Order) {
                            var $tr = $('<tr></tr>');

                            var $td = $('<td><div class="col-sm-8 ">\n' +
                                '                        <div class="checkbox-custom checkbox-default">\n' +
                                '                        <input class="procheck1" type="checkbox" spelno="'+Order.spelno+'"  status="'+Order.statusid+'" bookingno="'+Order.bookingid+'" value="'+Order.orderNumber+'" name="procheck">\n' +
                                '                        <label for="RememberMe" ></label>\n' +
                                '                        </div>\n' +
                                '                        </div></td>');
                            $tr.append($td);


                            $td = $('<td></td>');
                            $td.text(Order.spelno);
                            $tr.append($td);


                            $td = $('<td></td>');
                            $td.text(Order.orderNumber);
                            $tr.append($td);

                            $td = $('<td></td>');
                            $td.text(Order.bookingid);
                            $tr.append($td);

                            $td = $('<td></td>');
                            $td.text(Order.senderName+"/"+Order.goodDescription);
                            $tr.append($td);

                            $td = $('<td></td>');
                            $td.text(Order.cAddress+"/"+Order.cUsername);
                            $tr.append($td);

                            $td = $('<td></td>');
                            if (Order.shippingType==1 ){
                                $td.text("海运");
                            }else {
                                $td.text("空运");
                            }
                            $tr.append($td);


                            $td = $('<td></td>');
                            $td.text(Order.loadingport+"/"+Order.dischargeport);
                            $tr.append($td);

                            var   d=new   Date(Order.ordertime);
                            $td = $('<td></td>');
                            $td.text(formatDate(d));
                            $tr.append($td);



                            $td = $('<td></td>');
                            if (Order.statusid==6) {
                                $td.html('<button type="button" class="btn btn-success btn-xs">已反馈</button>');

                            }else if (Order.statusid==20) {
                                $td.html('<button type="button" class="btn btn-info btn-xs">已下发</button>');
                            }else if (Order.statusid==35) {
                                $td.html('<button type="button" class="btn btn-success btn-xs">已报关</button>');
                            }else {
                                $td.html('<button type="button" class="btn btn-info btn-xs">挂起</button>');
                            }
                            $tr.append($td);

                            $td = $('<td style="display: none"></td>');
                            $td.text(Order.id);
                            $tr.append($td);

                            $td = $('<td style="display: none"></td>');
                            $td.text(Order.statusid);
                            $tr.append($td);


                            $td = $('<td></td>');
                            $td.html('<a href="javascript:;" orderNumber="'+Order.orderNumber+'" class="btn btn-primary btn-xs showOrderAll" style="padding: 2px 8px;"><i class="fa fa-search-plus"></i></a>\n' +
                                '                    <a href="javascript:;" orderNumber="'+Order.orderNumber+'" status="'+Order.statusid+'" class="btn btn-danger btn-xs xiafa2" style="padding: 2px 8px;"><i class="fa fa-sort-amount-asc"></i></a>');
                            $tr.append($td);
                            $('#table1').append($tr);


                        })
                        $('#ye').find("li").remove();
                        $('#ye').prepend('<li><a class="page1" href="javascript:;" pageNum="'+(data.pageNum-1)+'" >&laquo;</a></li >');
                        $("#ye").append('<li><a>'+data.pageNum+"/"+data.pages+'</a></li>');
                        $('#ye').append('<li><a class="page1" href="javascript:;" pageNum="'+(data.pageNum+1)+'">&raquo;</a></li>');
                    },
                    error:function(){
                        alert("错误");
                    }
                })
            }
        });


        //普通搜索
        $(document).on("click",".gaoGetOrder",function () {
            var $pagenum=$(this).attr("pageNum");
            var $orderNumber = $("#orderNo").val();
            var $null = null;
                $.ajax({
                    type:"post",
                    xhrFields:{withCredentials:true},
                    url:"http://localhost:8081/OrderController/faOrder",
                    dataType:"json",
                    data:{"orderNumber":$orderNumber,"bookingid":$null,"statusid":$null,"exportorgname":$null,"salesmanid":$null,"customerName":$null,"pageNum":$pagenum,"token":$token},
                    success:function (data) {
                        if(data.list==0){
                            $("#table1").hide();
                            $("#tableError").show();
                            $("#tableError").html("抱歉,未找到数据");
                            return;
                        }
                        $("#tableError").hide();
                        $("#table1").show();
                        $('#table1 tbody').remove();
                        $.each(data.list,function(i,Order) {
                            var $tr = $('<tr></tr>');

                            var $td = $('<td><div class="col-sm-8 ">\n' +
                                '                        <div class="checkbox-custom checkbox-default">\n' +
                                '                        <input class="procheck1" type="checkbox" spelno="'+Order.spelno+'" status="'+Order.statusid+'" bookingno="'+Order.bookingid+'" value="'+Order.orderNumber+'" name="procheck">\n' +
                                '                        <label for="RememberMe" ></label>\n' +
                                '                        </div>\n' +
                                '                        </div></td>');
                            $tr.append($td);


                            $td = $('<td></td>');
                            $td.text(Order.spelno);
                            $tr.append($td);


                            $td = $('<td></td>');
                            $td.text(Order.orderNumber);
                            $tr.append($td);

                            $td = $('<td></td>');
                            $td.text(Order.bookingid);
                            $tr.append($td);

                            $td = $('<td></td>');
                            $td.text(Order.senderName+"/"+Order.goodDescription);
                            $tr.append($td);

                            $td = $('<td></td>');
                            $td.text(Order.cAddress+"/"+Order.cUsername);
                            $tr.append($td);

                            $td = $('<td></td>');
                            if (Order.shippingType==1 ){
                                $td.text("海运");
                            }else {
                                $td.text("空运");
                            }
                            $tr.append($td);


                            $td = $('<td></td>');
                            $td.text(Order.loadingport+"/"+Order.dischargeport);
                            $tr.append($td);

                            var   d=new   Date(Order.ordertime);
                            $td = $('<td></td>');
                            $td.text(formatDate(d));
                            $tr.append($td);



                            $td = $('<td></td>');
                            if (Order.statusid==6) {
                                $td.html('<button type="button" class="btn btn-success btn-xs">已反馈</button>');

                            }else if (Order.statusid==20) {
                                $td.html('<button type="button" class="btn btn-info btn-xs">已下发</button>');
                            }else if (Order.statusid==35) {
                                $td.html('<button type="button" class="btn btn-success btn-xs">已报关</button>');
                            }else {
                                $td.html('<button type="button" class="btn btn-info btn-xs">挂起</button>');
                            }
                            $tr.append($td);

                            $td = $('<td style="display: none"></td>');
                            $td.text(Order.id);
                            $tr.append($td);

                            $td = $('<td style="display: none"></td>');
                            $td.text(Order.statusid);
                            $tr.append($td);


                            $td = $('<td></td>');
                            $td.html('<a href="javascript:;" orderNumber="'+Order.orderNumber+'" class="btn btn-primary btn-xs showOrderAll" style="padding: 2px 8px;"><i class="fa fa-search-plus"></i></a>\n' +
                                '                    <a href="javascript:;" orderNumber="'+Order.orderNumber+'" status="'+Order.statusid+'" class="btn btn-danger btn-xs xiafa2" style="padding: 2px 8px;"><i class="fa fa-sort-amount-asc"></i></a>');
                            $tr.append($td);
                            $('#table1').append($tr);


                        })
                        $('#ye').find("li").remove();
                        $('#ye').prepend('<li><a class="page1" href="javascript:;" pageNum="'+(data.pageNum-1)+'" >&laquo;</a></li >');
                        $("#ye").append('<li><a>'+data.pageNum+"/"+data.pages+'</a></li>');
                        $('#ye').append('<li><a class="page1" href="javascript:;" pageNum="'+(data.pageNum+1)+'">&raquo;</a></li>');
                    },
                    error:function(){
                        alert("错误");
                    }
                })

        });

        //点击下发
        $(document).on("click",".xiafa",function  () {
            if($("input[name='procheck']:checked").length==1){
                if ($("input[name='procheck']:checked").attr("status")==35){
                    $.ajax({
                        type:"post",
                        xhrFields:{withCredentials:true},
                        url:"http://localhost:8081/OrderController/xiafa",
                        dataType:"json",
                        data:{"orderNumber":$("input[name='procheck']:checked").val(),"token":$token},
                        success:function (data) {
                            if(data.message=="no"){
                                alert("无法下发");
                                return;
                            }else if(data.message=="yes"){
                                window.location.reload();
                            }else{
                                alert("下发失败");
                            }

                        },
                        error:function(){
                            alert("异常");
                        }
                    });
                }else {
                    alert("挂起的订单无法下发");
                }
            }else {
                alert("无法同时下发,请选择集拼下发!");
            }
        });





        //点击集拼下发
        $(document).on("click",".allxiafa",function  () {
            if($("input[class='procheck1']:checked").length!=0){
                var checkID = [];//定义一个空数组
                var check2 = $("input[class='procheck1']:checked").attr("spelno");
                var checkSpelno = [];
                var flag = true;
                $("input[class='procheck1']:checked").each(function(i){//把所有被选中的复选框的值存入数组
                    checkID[i] =$(this).attr("spelno");
                    // checkSpelno[i] = $(this).attr("statusid");
                    if (check2!=checkID[i]){
                        flag = false;
                    }
                });
                if (!flag){
                    alert("不同集拼号无法集拼下发");
                }else {
                    $.ajax({
                            async : false,
                             cache : false,
                             traditional: true,
                            type:"post",
                            xhrFields:{withCredentials:true},
                            url:"http://localhost:8081/OrderController/allxiafa",
                            dataType:"json",
                            data:{"spelnos":check2,"token":$token},
                            success:function (data) {
                                if(data.message=="no"){
                                    alert("无法集拼下发");
                                    return;
                                }else if(data.message=="yes"){
                                    window.location.reload();
                                }else{
                                    alert("集拼下发失败");
                                }

                            },
                            error:function(){
                                alert("异常");
                            }
                        });
                }

            }
        });


        //点击挂起
        $(document).on("click","#guaqi",function  () {
            if($("input[name='procheck']:checked").length==1){
                if ($("input[name='procheck']:checked").attr("status")==35){
                    $.ajax({
                        type:"post",
                        xhrFields:{withCredentials:true},
                        url:"http://localhost:8081/OrderController/guaqi",
                        dataType:"json",
                        data:{"orderNumber":$("input[name='procheck']:checked").val(),"token":$token},
                        success:function (data) {
                            if(data.message=="no"){
                                alert("无法挂起");
                                return;
                            }else if(data.message=="yes"){
                                window.location.reload();
                            }else{
                                alert("挂起失败");
                            }

                        },
                        error:function(){
                            alert("异常");
                        }
                    });
                }else {
                    alert("该订单无法挂起");
                }
            }else {
                alert("无法同时挂起!");
            }
        });

        //点击取消挂起
        $(document).on("click","#noguaqi",function  () {
            if($("input[name='procheck']:checked").length==1){
                if ($("input[name='procheck']:checked").attr("status")==21){
                    $.ajax({
                        type:"post",
                        xhrFields:{withCredentials:true},
                        url:"http://localhost:8081/OrderController/noguaqi",
                        dataType:"json",
                        data:{"orderNumber":$("input[name='procheck']:checked").val(),"token":$token},
                        success:function (data) {
                            if(data.message=="no"){
                                alert("无法取消挂起");
                                return;
                            }else if(data.message=="yes"){
                                window.location.reload();
                            }else{
                                alert("取消挂起失败");
                            }

                        },
                        error:function(){
                            alert("异常");
                        }
                    });
                }else {
                    alert("该订单无法取消挂起!");
                }
            }else {
                alert("无法同时取消挂起!");
            }
        });
// <!--end!-->

        $(document).on("click",".page1",function () {
            var $pagenum=$(this).attr("pageNum");
            var $orderNumber = $("#orderNo").val();
            var $null = null;
            $.ajax({
                type:"post",
                xhrFields:{withCredentials:true},
                url:"http://localhost:8081/OrderController/faOrder",
                dataType:"json",
                data:{"orderNumber":$orderNumber,"bookingid":$null,"statusid":$null,"exportorgname":$null,"salesmanid":$null,"customerName":$null,"pageNum":$pagenum,"token":$token},
                success:function (data) {
                    if(data.list==0){
                        $("#table1").hide();
                        $("#tableError").show();
                        $("#tableError").html("抱歉,未找到数据");
                        return;
                    }
                    $("#tableError").hide();
                    $("#table1").show();
                    $('#table1 tbody').remove();
                    $.each(data.list,function(i,Order) {
                        var $tr = $('<tr></tr>');

                        var $td = $('<td><div class="col-sm-8 ">\n' +
                            '                        <div class="checkbox-custom checkbox-default">\n' +
                            '                        <input class="procheck1" type="checkbox" spelno="'+Order.spelno+'" status="'+Order.statusid+'" bookingno="'+Order.bookingid+'" value="'+Order.orderNumber+'" name="procheck">\n' +
                            '                        <label for="RememberMe" ></label>\n' +
                            '                        </div>\n' +
                            '                        </div></td>');
                        $tr.append($td);


                        $td = $('<td></td>');
                        $td.text(Order.spelno);
                        $tr.append($td);


                        $td = $('<td></td>');
                        $td.text(Order.orderNumber);
                        $tr.append($td);

                        $td = $('<td></td>');
                        $td.text(Order.bookingid);
                        $tr.append($td);

                        $td = $('<td></td>');
                        $td.text(Order.senderName+"/"+Order.goodDescription);
                        $tr.append($td);

                        $td = $('<td></td>');
                        $td.text(Order.cAddress+"/"+Order.cUsername);
                        $tr.append($td);

                        $td = $('<td></td>');
                        if (Order.shippingType==1 ){
                            $td.text("海运");
                        }else {
                            $td.text("空运");
                        }
                        $tr.append($td);


                        $td = $('<td></td>');
                        $td.text(Order.loadingport+"/"+Order.dischargeport);
                        $tr.append($td);

                        var   d=new   Date(Order.ordertime);
                        $td = $('<td></td>');
                        $td.text(formatDate(d));
                        $tr.append($td);



                        $td = $('<td></td>');
                        if (Order.statusid==6) {
                            $td.html('<button type="button" class="btn btn-success btn-xs">已反馈</button>');

                        }else if (Order.statusid==20) {
                            $td.html('<button type="button" class="btn btn-info btn-xs">已下发</button>');
                        }else if (Order.statusid==35) {
                            $td.html('<button type="button" class="btn btn-success btn-xs">已报关</button>');
                        }else {
                            $td.html('<button type="button" class="btn btn-info btn-xs">挂起</button>');
                        }
                        $tr.append($td);

                        $td = $('<td style="display: none"></td>');
                        $td.text(Order.id);
                        $tr.append($td);

                        $td = $('<td style="display: none"></td>');
                        $td.text(Order.statusid);
                        $tr.append($td);


                        $td = $('<td></td>');
                        $td.html('<a href="javascript:;" orderNumber="'+Order.orderNumber+'" class="btn btn-primary btn-xs showOrderAll" style="padding: 2px 8px;"><i class="fa fa-search-plus"></i></a>\n' +
                            '                    <a href="javascript:;" orderNumber="'+Order.orderNumber+'" status="'+Order.statusid+'" class="btn btn-danger btn-xs xiafa2" style="padding: 2px 8px;"><i class="fa fa-sort-amount-asc"></i></a>');
                        $tr.append($td);
                        $('#table1').append($tr);


                    })
                    $('#ye').find("li").remove();
                    $('#ye').prepend('<li><a class="page1" href="javascript:;" pageNum="'+(data.pageNum-1)+'" >&laquo;</a></li >');
                    $("#ye").append('<li><a>'+data.pageNum+"/"+data.pages+'</a></li>');
                    $('#ye').append('<li><a class="page1" href="javascript:;" pageNum="'+(data.pageNum+1)+'">&raquo;</a></li>');
                },
                error:function(){
                    alert("错误");
                }
            })

        });
        //点击右边的查看
        $(document).on("click",".showOrderAll",function  () {
            window.location.href='sys_order_info.html?orderNumber='+$(this).attr("orderNumber");
        });

        //点击右边的下发按钮
        $(document).on("click",".xiafa2",function  () {
                if ($(this).attr("status")==6){
                    $.ajax({
                        type:"post",
                        xhrFields:{withCredentials:true},
                        url:"http://localhost:8081/OrderController/xiafa",
                        dataType:"json",
                        data:{"orderNumber":$(this).attr("orderNumber"),"token":$token},
                        success:function (data) {
                            if(data.message=="no"){
                                alert("无法下发");
                                return;
                            }else if(data.message=="yes"){
                                window.location.reload();
                            }else{
                                alert("下发失败");
                            }

                        },
                        error:function(){
                            alert("异常");
                        }
                    });
                }else {
                    alert("此订单无法下发");
                }



        });



      $(window).load(function() {
      	$("#head").load("head.html");
      	$("#gsearch").click(function(){
 					 $("#bbb").toggle();
				});
      	$(".aa").click(function  () {
      		var $check=$("#RememberMe1").prop("checked");
      		if($check==true){
					$("input[name='procheck']").prop("checked", true);
					}else if($check==false){
						$("input[name='procheck']").prop("checked", false);
					}
      	});
        var date = new Date(),
            d = date.getDate(),
            m = date.getMonth(),
            y = date.getFullYear(),
            started,
            categoryClass;

        var calendar = $('#calendar').fullCalendar({
          header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
          },
          selectable: true,
          selectHelper: true,
          select: function(start, end, allDay) {
            $('#fc_create').click();

            started = start;
            ended = end;

            $(".antosubmit").on("click", function() {
              var title = $("#title").val();
              if (end) {
                ended = end;
              }

              categoryClass = $("#event_type").val();

              if (title) {
                calendar.fullCalendar('renderEvent', {
                    title: title,
                    start: started,
                    end: end,
                    allDay: allDay
                  },
                  true // make the event "stick"
                );
              }

              $('#title').val('');

              calendar.fullCalendar('unselect');

              $('.antoclose').click();

              return false;
            });
          },
          eventClick: function(calEvent, jsEvent, view) {
            $('#fc_edit').click();
            $('#title2').val(calEvent.title);

            categoryClass = $("#event_type").val();

            $(".antosubmit2").on("click", function() {
              calEvent.title = $("#title2").val();

              calendar.fullCalendar('updateEvent', calEvent);
              $('.antoclose2').click();
            });

            calendar.fullCalendar('unselect');
          },
          editable: true,
          events: [{
            title: 'All Day Event',
            start: new Date(y, m, 1)
          }, {
            title: 'Long Event',
            start: new Date(y, m, d - 5),
            end: new Date(y, m, d - 2)
          }, {
            title: 'Meeting',
            start: new Date(y, m, d, 10, 30),
            allDay: false
          }, {
            title: 'Lunch',
            start: new Date(y, m, d + 14, 12, 0),
            end: new Date(y, m, d, 14, 0),
            allDay: false
          }, {
            title: 'Birthday Party',
            start: new Date(y, m, d + 1, 19, 0),
            end: new Date(y, m, d + 1, 22, 30),
            allDay: false
          }, {
            title: 'Click for Google',
            start: new Date(y, m, 28),
            end: new Date(y, m, 29),
            url: 'http://google.com/'
          }]
        });
      });
    </script>
    <!-- /FullCalendar -->
  </body>
</html>

